home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / bin / sensible-editor < prev    next >
Text File  |  2009-02-16  |  845b  |  39 lines

  1. #!/bin/sh
  2.  
  3. ret="$?"
  4.  
  5. if [ -n "$VISUAL" ]; then
  6.     ${VISUAL} "$@"
  7.     ret="$?"
  8.     if [ "$ret" -ne 126 ] && [ "$ret" -ne 127 ]; then
  9.         exit "$ret"
  10.     fi
  11. fi
  12.  
  13. if [ -r ~/.selected_editor ]; then
  14.     . ~/.selected_editor 2>/dev/null || true
  15. elif [ -z "$EDITOR" ] && [ -z "$SELECTED_EDITOR" ] && [ -t 0 ]; then
  16.     select-editor && . ~/.selected_editor 2>/dev/null || true
  17. fi
  18.  
  19. ${EDITOR:-${SELECTED_EDITOR:-editor}} "$@"
  20. ret="$?"
  21. if [ "$ret" -eq 126 ] || [ "$ret" -eq 127 ]; then
  22.     nano "$@"
  23.     ret="$?"
  24.     if [ "$ret" -eq 126 ] || [ "$ret" -eq 127 ]; then
  25.         nano-tiny "$@"
  26.         ret="$?"
  27.         if [ "$ret" -eq 126 ] || [ "$ret" -eq 127 ]; then
  28.             vi "$@"
  29.             ret="$?"
  30.             if [ "$ret" -eq 126 ] || [ "$ret" -eq 127 ]; then
  31.                 echo "Couldn't find an editor!" 1>&2
  32.                 echo "Set the \$EDITOR environment variable to your desired editor." 1>&2
  33.                 exit 1
  34.             fi
  35.         fi
  36.     fi
  37. fi
  38. exit "$ret"
  39.